//public class java0516 {
//    public static void main(String[] args) {
//        int a = 18;
//        int b = 12;
//        int c = a % b;
//        while(c != 0){
//            a = b;
//            b = c;
//            c = a % b;  //这三个算式在一起才能实现找最大公约数的功能
//        }
//        System.out.println(b);
//    }
//}

import java.util.Scanner;

public class java0516 {
    public static void main(String[] args) {
       int i = 0;

       for(i = 0;i < 999999;i++){
           int num = i;
           int count = 0;        //count没有被重置导致程序运行错误
           while(num != 0){
               count++;
               num /= 10;
           }
           num = i;
           int sum = 0;
           while(num != 0){
               sum += Math.pow(num % 10,count);
               num /= 10;

           }
           if(sum == i){
               System.out.println(count+" 位的自幂数为"+ i );
           }
       }
    }
}

